package com.example.edu.Mapper;

import com.example.edu.Entity.Tag;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TagMapper {
    void insertMany(@Param("tags") List<Tag> tags);

    @Select("select t.tag_id,t.tag_name from tag t left join article_tag at on t.tag_id = at.tag_id where at.article_id is null and t.is_static = 0")
    List<Tag> getWildTag();

    void deleteByNames(@Param("tag_names") List<String> tag_names);

    List<String> getTagNames(@Param("tag_ids") List<Integer> tag_ids);

    @Select("select tag_name from tag where is_static = 1")
    List<String> getStatic();

    @Select("select t.tag_name,t.tag_id from article_tag at join tag t on at.tag_id = t.tag_id where telephone = #{telephone}")
    List<Tag> getTags(@Param("telephone") String telephone);

    @Select("select tag_id,tag_name from tag")
    List<Tag> getAllTags();
}
